package While循环;

import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        int num=(int)(Math.random()*100+1);
        Scanner sc=new Scanner(System.in);
        int guess=1;
        int count=1;
        while(num!=guess){
            System.out.println("请猜一个数");
             guess=sc.nextInt();
            if(num>guess){
                System.out.println("猜小了");
            }else if(num<guess){
                System.out.println("猜大了");
            }
            count++;
        }
        System.out.println("猜对了");
        System.out.println("猜的次数"+count);
    }
}
